
df = open_dataset('data/final_long') %>%
  count(cycle, in_fec, in_l2, in_cl) %>%
  collect() %>%
  as.data.table()

# cl obs
df[in_cl == 1, sum(n), cycle]
# l2 obs
df[in_l2 == 1, sum(n), cycle]
# fec obs
df[in_fec == 1, sum(n), cycle]

# in L2 pct for FEC
df[in_l2 == 1, sum(n[in_fec == 1]) / sum(n) , cycle]
# in CL pct for FEC
df[in_cl == 1, sum(n[in_fec == 1]) / sum(n) , cycle]

# in FEC pct for L2
df[in_fec == 1, sum(n[in_l2 == 1]) / sum(n) , cycle]
# in CL pct for L2
df[in_cl == 1, sum(n[in_l2 == 1]) / sum(n) , cycle]

# in L2 pct for CL
df[in_l2 == 1, sum(n[in_cl == 1]) / sum(n) , cycle]
# in FEC pct for CL
df[in_fec == 1, sum(n[in_cl == 1]) / sum(n) , cycle]
